<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:apabb="http://apabb.org.br/jsf"
	template="../template/template.xhtml">

	<ui:define name="nucleoBase">

		<h:form id="formBem">

			<div style="position: relative; left: 11px; font-size: 120%;">
				<h2>Manter Requisicao</h2>
			</div>
			<hr size="3" style="left: 10px; background-color: #000080;" />

			<div id="idEditaRequisicao">
				<div style="position: relative; left: 11px;">
					<h:messages
						errorStyle="color: red; font-family: Arial; 
								 position: relative; left: 10px; font-size: 12px; font-weight: bold;"
						infoClass="info" showSummary="true" />
				</div>
				<br />
				<fieldset styleClass="form"
					style="background-color: rgb(240, 250, 255)">
					<br />
					<h:panelGrid columns="2" width="43%">
					
						<h:column>
							<h:outputLabel for="usuario" value="Usuario: " />
						</h:column>
						<h:column>
							<h:inputText value="#{requisicaoView.requisicao.usuario.nomeUsuario}" disabled="true"/>
						</h:column>
						
						<h:column>
							<h:outputLabel for="Setor" value="Setor: " />
						</h:column>
						<h:column>
							<h:inputText value="#{requisicaoView.requisicao.usuario.setor.nomeSetor}" disabled="true" />
						</h:column>
						
						<h:column>
							<h:outputLabel for="tipo_pat" value="Tipo: " />
						</h:column>
						<h:column>
							<h:selectOneMenu styleClass="inputContrast" name="tipo_pat" rendered="true"
								id="tipo_pat"
								value="#{requisicaoView.requisicao.tipoPatrimonio}" label="Tipo">
								<f:selectItem itemLabel="- Selecione -"/>
								<f:selectItems value="#{requisicaoView.listaTipoPatrimonio}" />
							</h:selectOneMenu>
						</h:column>
						
						<h:column>
							<h:outputLabel for="justificativa" value="Justificativa: " />
						</h:column>
						<h:column>
							<h:inputTextarea value="#{requisicaoView.requisicao.justificativa}" name="justificativa"
								required="true" />
						</h:column>
						
						<h:column>
							<h:outputLabel for="data"
								value="Data: " title="data" />
						</h:column>
						<h:column>
							<rich:calendar styleClass="contractRich"
								label="Data" disabled="true"
								value="#{requisicaoView.requisicao.dataReqisicao}"
								datePattern="dd/MM/yyyy" enableManualInput="true"
								oninputkeyup="formataMascara('##/##/####', this)"
								oninputchange="formataMascara('##/##/####', this)"
								maxlength="10">
							</rich:calendar>
						</h:column>
						<br />
					</h:panelGrid>
					<h:panelGrid columns="2" width="83%" rendered="#{usuarioLogado.idAcesso eq 2}">
						<h:column>
							<h:selectOneRadio id="radioStatus"
								value="#{requisicaoView.requisicao.statusRequisicao}">
								<f:selectItem itemValue="2" itemLabel="Negado" />
								<f:selectItem itemValue="3" itemLabel="Aprovado" />
							</h:selectOneRadio>
						</h:column>
					</h:panelGrid>
					
					<h:panelGrid columns="2" width="83%" rendered="#{usuarioLogado.idAcesso eq 1}">
						<h:column>
							<a4j:commandButton render="formBem"
										action="#{requisicaoView.pesquisarPatrimonio}" id="btnConsDisponivel"
										
										value="  Pesquisar disponibilidade  " />
						</h:column>
						<h:column />
						
						<a4j:outputPanel id="outPutPanelListaBem">
						<br />

					<fieldset>

						<div style="overflow: auto;">
							<div align="center">
								<h:outputText
									rendered="#{requisicaoView.exibeMsgNenhumRegistroEncontrado}"
									value="Nenhum registro encontrado." />
							</div>
							<h:dataTable id="TabelaProgramas"
								rendered="#{not empty requisicaoView.listaPatrimonio}"
								value="#{requisicaoView.listaPatrimonio}" var="patrimonio" width="100%"
								headerClass="tbhead">
								<h:column>
									<f:facet name="header">
										<h:outputText value="Patrimonio" />
									</f:facet>

									<div align="center">
										<h:commandLink action="#{requisicaoView.detalhar}"
											value="#{patrimonio.codigoPatrimonio}">
											<f:setPropertyActionListener target="#{requisicaoView.patrimonio}"
												value="#{patrimonio}" />
										</h:commandLink>
									</div>
								</h:column>

								<h:column>
										<f:facet name="header">
											<h:outputText value="Modelo" />
										</f:facet>
									<div align="center">
										#{patrimonio.nomePatrimonio}
									</div>
								</h:column>


								<h:column>
										<f:facet name="header">
											<h:outputText value="Tipo" />
										</f:facet>
									<div align="center">
										<h:outputText value="#{patrimonio.descTipoPatrimonio}" />
									</div>
								</h:column>
								
								<h:column>
										<f:facet name="header">
											<h:outputText value="Setor" />
										</f:facet>
									<div align="center">
										<h:outputText value="#{patrimonio.setor.nomeSetor}" />
									</div>
								</h:column>

								<h:column>
									<f:facet name="header">
										<h:outputText value="Alocar" />
									</f:facet>

									<div align="center">
										<a4j:commandLink action="#{requisicaoView.alocarPatrimonio}">
											<h:graphicImage value="" alt="Excluir"
												url="../images/alocar.jpg" height="20px" width="20px" />
											<f:setPropertyActionListener target="#{requisicaoView.patrimonio}"
												value="#{patrimonio}" />
										</a4j:commandLink>
									</div>
								</h:column>
							</h:dataTable>

						</div>

					</fieldset>

				</a4j:outputPanel>
					</h:panelGrid>
					
					<span style="color: red;">(*)Campo de preenchimento
						obrigatório.</span> <br />

					<div align="right">

						<table border="1" width="20%">
							<tr>
								<td><h:commandButton action="#{requisicaoView.voltar}"
										id="btnVoltar" immediate="true" value="   Voltar  "
										 /></td>
								<td>&nbsp;&nbsp;&nbsp;</td>
								<td><a4j:commandButton render="formBem"
										action="#{requisicaoView.popupSalvar}" id="btnSalvar"
										rendered="#{requisicaoView.requisicao.codigo == null}"
										value="  Incluir  " /> <a4j:commandButton
										render="formBem" action="#{requisicaoView.popupAtualizar}"
										id="btnSalvar2"
										rendered="#{requisicaoView.requisicao.codigo != null}"
										value="  Alterar  " /></td>
							</tr>

						</table>
					</div>

				</fieldset>


			</div>

			<apabb:popupConfirmacao componentView="#{requisicaoView}"
				form="formBem" />

		</h:form>
	</ui:define>
</ui:composition>
